//
//  LiveTableViewCell.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/11.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "LiveTableViewCell.h"

@interface LiveTableViewCell ()

@property(nonatomic,strong)UIImageView *shuxian;
@property(nonatomic,strong)UIImageView *hengxian;
@property(nonatomic,strong)UIView *matchInfoView;

@end

@implementation LiveTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat gap = kScreenIp6(10);

        CGFloat backgroundViewW = kScreenWidth - 2 * gap;

        self.backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(gap, gap, backgroundViewW, kScreenIp6(70))];
        self.backgroundImageView.userInteractionEnabled= YES;
        self.backgroundImageView.image = [UIImage imageNamed:@"btn_bg_green_1"];
        [self addSubview:_backgroundImageView];
        CGFloat gapTwo = gap / 2;
        self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(gapTwo, gapTwo, kScreenIp6(70), kScreenIp6(60))];
        _timeLabel.text = @"00 : 00";
        _timeLabel.textAlignment = 1;
        _timeLabel.font = [UIFont systemFontOfSize:17];
        //self.timeLabel.backgroundColor = [UIColor redColor];
        [self.backgroundImageView addSubview:_timeLabel];
        
        self.lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_timeLabel.frame), gapTwo, 1, kScreenIp6(60))];
        _lineImageView.image = [UIImage imageNamed:@"adchina_toolbar"];
        [self.backgroundImageView addSubview:_lineImageView];
        
        self.attention = [UIButton buttonWithType:UIButtonTypeSystem];
        [_attention setBackgroundImage:[UIImage imageNamed:@"football_collect_small_1"] forState:UIControlStateNormal];
        CGFloat attentionY = gapTwo;
        _attention.frame = CGRectMake(kScreenWidth - kScreenIp6(80), attentionY, kScreenIp6(60), kScreenIp6(60));
//        _attention.backgroundColor = [UIColor blueColor];
        [self.backgroundImageView addSubview:_attention];
        
        CGFloat matchViewW = CGRectGetMinX(_attention.frame) - CGRectGetMaxX(_timeLabel.frame) - gapTwo * 2;
        self.matchView = [[UIView alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_timeLabel.frame), gapTwo, matchViewW , kScreenIp6(60))];
//        _matchView.backgroundColor = [UIColor orangeColor];
        [self.backgroundImageView addSubview:_matchView];
        
        CGFloat matchLabelW = _matchView.frame.size.width - gapTwo * 2;
        self.matchLabel = [[UILabel alloc] initWithFrame:CGRectMake(gap, 0,matchLabelW , kScreenIp6(40))];
        self.matchLabel.adjustsFontSizeToFitWidth = YES;
        self.matchLabel.textAlignment = NSTextAlignmentCenter;
        [self.matchView addSubview:_matchLabel];
        
        CGFloat propertyW = kScreenIp6(100);
        self.property = [[UILabel alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_matchLabel.frame), propertyW, kScreenIp6(12))];
        //self.backgroundColor = [UIColor orangeColor];
        _property.text = @"比赛信息";
        _property.textAlignment = 1;
        _property.font = [UIFont systemFontOfSize:13];
        _property.textColor = [UIColor grayColor];
//        _property.backgroundColor = [UIColor redColor];
        [self.matchView addSubview:_property];
        
        self.channeLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_property.frame), CGRectGetMaxY(_matchLabel.frame), matchLabelW - propertyW + kScreenIp6(20), kScreenIp6(12))];
//        self.channeLabel.backgroundColor = [UIColor greenColor];
        _channeLabel.font = [UIFont systemFontOfSize:13];
        _channeLabel.textAlignment = NSTextAlignmentCenter;
        [self.matchView addSubview:_channeLabel];
        
        //线
//        UIView *footLineView = [[UIView  alloc]initWithFrame:CGRectMake( 0, kScreenIp6(90), kScreenWidth, 0.5)];
//        
//        footLineView.backgroundColor = [UIColor colorWithWhite:0.699 alpha:1.000];
//        
//        // 设置 cell 点击没有变化
//        self.selectionStyle = UITableViewCellSelectionStyleNone;
//        
//        [self addSubview:footLineView];
        
    }
    return self;
}

- (void)setDataWithModel:(ListArrayModel *)model
{
    self.timeLabel.text = model.time;
    self.property.text = model.matchProperty;
    self.matchLabel.text = model.matchInfo;
    if ([model.keywords isEqualToString:@""]) {
        self.channeLabel.text = @"比分直播";
    }
    else
    {
        self.channeLabel.text = model.keywords;
    }
}

@end
